home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-06-28 | 2.8 KB | 142 lines | [TEXT/CWIE] |
- // PaneColumnBase.cp
-
- #ifndef PaneColumnBase_h
- #include "PaneColumnBase.h"
- #endif
- #ifndef MinMax_h
- #include "MinMax.h"
- #endif
- #ifndef ArrangementLoop_h
- #include "ArrangementLoop.h"
- #endif
- #ifndef ConstArrangementLoop_h
- #include "ConstArrangementLoop.h"
- #endif
-
- void PaneColumnBase::Arrange( Rectangle bounds )
- {
- uint16 minimum = MinimumHeight();
- uint16 height = bounds.Height();
-
- uint16 slop = ( height > minimum )
- ? height - minimum
- : 0;
-
- uint16 sloppySlop = ( slop > 0 )
- ? height - BestHeight( height )
- : 0;
-
- int16 topSide = bounds.top;
-
- for ( ArrangementLoop pane( *this ); pane.Unfinished(); pane++ )
- {
- uint16 paneMinimum = (*pane)->MinimumHeight();
-
- uint16 paneHeight = ( slop > 0 )
- ? (*pane)->BestHeight( paneMinimum + slop )
- : Min( height, paneMinimum );
-
- if ( sloppySlop > 0 )
- {
- paneHeight += sloppySlop;
- sloppySlop = 0;
- }
-
- Assert( paneHeight <= height );
- height -= paneHeight;
- if ( paneHeight > paneMinimum )
- slop -= paneHeight - paneMinimum;
-
- Rectangle paneArea( bounds.left,
- topSide,
- bounds.right,
- topSide + paneHeight );
- Assert( bounds >= paneArea );
-
- pane->SetBounds( paneArea );
- topSide = paneArea.bottom;
- }
- }
-
- uint16 PaneColumnBase::MinimumHeight() const
- {
- return Total( &Sizeable::MinimumHeight );
- }
-
- uint16 PaneColumnBase::MinimumWidth() const
- {
- return Maximum( &Sizeable::MinimumWidth );
- }
-
- uint16 PaneColumnBase::MaximumHeight() const
- {
- return Total( &Sizeable::MaximumHeight );
- }
-
- uint16 PaneColumnBase::MaximumWidth() const
- {
- return Minimum( &Sizeable::MaximumWidth );
- }
-
- uint16 PaneColumnBase::ReasonableHeight() const
- {
- return Total( &Sizeable::ReasonableHeight );
- }
-
- uint16 PaneColumnBase::ReasonableWidth() const
- {
- return Maximum( &Sizeable::ReasonableWidth );
- }
-
- uint16 PaneColumnBase::BestHeight() const
- {
- return Total( &Sizeable::BestHeight );
- }
-
- uint16 PaneColumnBase::BestHeight( uint16 bound ) const
- {
- uint16 minimum = MinimumHeight();
-
- if ( bound <= minimum )
- return bound;
-
- uint16 slop = bound - minimum;
-
- uint16 height = 0;
- for ( ConstArrangementLoop pane( *this ); pane.Unfinished(); pane++ )
- {
- uint16 paneMinimum = (*pane)->MinimumHeight();
- uint16 paneHeight = (*pane)->BestHeight( paneMinimum + slop );
-
- Assert( paneHeight >= paneMinimum );
-
- if ( !CanAdd( height, paneHeight ) )
- return maxuint16;
-
- height += paneHeight;
- slop -= paneHeight - paneMinimum;
- }
-
- Assert( height <= bound );
- return height;
- }
-
- uint16 PaneColumnBase::BestWidth() const
- {
- return Maximum( &Sizeable::BestWidth );
- }
-
- uint16 PaneColumnBase::BestWidth( uint16 bound ) const
- {
- uint16 best = 0;
-
- for ( ConstArrangementLoop pane( *this ); pane.Unfinished(); pane++ )
- {
- uint16 width = (*pane)->BestWidth( bound );
- if ( width > best )
- best = width;
- }
-
- return best;
- }
-